layui.use(['layer', 'form'], function() {

    var layer = layui.layer
        ,form = layui.form;
    $(function() {
        form.on('submit(formDemo)', function(data) {
            var uAccount = $("#account").val();
            var uName = $(".uName").val();
            var uSex = $(".uSex:checked").val();
            var date = $("#birthday").val();
            var uPhone = $(".uPhone").val();
            var uIco = $("#uIco").val();
            var uEmail = $(".uEmail").val();
            $.ajax({
                url:"/admin/addUser",
                type:"post",
                data:{uAccount:uAccount,uName:uName,uSex:uSex,uPhone:uPhone,uBirthday:date,uIco:uIco,uEmail:uEmail},
                success:function (result) {
                    if (result.code == 200){
                        //注册成功
                        layer.msg(result.msg, {icon: 1}, {
                            time: 1500
                        });
                        setTimeout(function () {
                            //调用父页面的方法
                            parent.tools.reloadTable();

                            //当你在iframe页面关闭自身时
                            var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                            parent.layer.close(index); //再执行关闭
                        }, 1500);
                    } else {
                        layer.msg(result.msg, {icon: 2}, {
                            time: 1500
                        });
                    }
                }
            });
            return false;
        });
    });
});